# $Id$
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>

pkgname=libphonenumber
pkgver=8.8.1
pkgrel=1
pkgdesc="Google's common library for parsing, formatting, and validating international phone numbers"
url="https://github.com/googlei18n/libphonenumber"
arch=(i686 x86_64)
license=(Apache)
depends=(icu protobuf boost-libs)
makedepends=(boost cmake gtest git java-environment ninja)
_commit=648d6427a7abbdb79a7a3e9ce97b8b230a61fef8  # tags/v8.8.1^0
source=("git+$url#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^libphonenumber-\|^v//;s/-/+/g'
}

prepare() {
  mkdir -p build
}

build() {
  cd build
  CXXFLAGS+=" -Wno-error=deprecated-declarations"  # readdir_r deprecation
  CXXFLAGS+=" -Wno-error=unused-variable"  # this is nuts
  cmake ../$pkgname/cpp -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr
  ninja
}

check() {
  cd build
  ninja tests
}

package() {
  cd build
  DESTDIR="$pkgdir" ninja install
}
